import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getChipDetail from '../resolves/getChipDetail.js';

import chipHtml from 'ngtemplate!html!../../../tpls/chip/chip.html';
import chipListHtml from 'ngtemplate!html!../../../tpls/chip/chip.list.html';
import chipImportHtml from 'ngtemplate!html!../../../tpls/chip/chip.import.html';


/**
 * ChipRouter - config
 * 赛事模块路由设置
 */
ChipRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];
function ChipRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {

	//set router
    $stateProvider
		
		// 导入芯片信息
		.state('dashboard.race.chipimport', {
		    url: '/chip/import',
		    data: { 
		        pageTitle: '导入芯片信息' 
		    },
		    templateUrl: chipImportHtml,
		    controller: 'ChipImportController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn([loadPlugin.dropzone])
		    }
		})

		// 新增计时芯片
		.state('dashboard.race.chip', {
		    url: '/chip',
		    data: { 
		        pageTitle: '新增计时芯片' 
		    },
		    templateUrl: chipHtml,
		    controller: 'ChipController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn([loadPlugin.icheck, loadPlugin.blink])
		    }
		})

		// 计时芯片列表
		.state('dashboard.race.chiplist', {
		    url: '/chip/list',
		    data: { 
		        pageTitle: '计时芯片列表' 
		    },
		    templateUrl: chipListHtml,
		    controller: 'ChipListController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn(loadPlugin.dataTables)
            }
		})

		// 编辑计时芯片
		.state('dashboard.race.chipedit', {
		    url: '/chip/edit?id',
		    data: { 
		        pageTitle: '编辑计时芯片' 
		    },
		    templateUrl: chipHtml,
		    controller: 'ChipEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getChipDetail: getChipDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.icheck, loadPlugin.blink])
		    }
		});

}

export default ChipRouter; 